<%--
  Created by IntelliJ IDEA.
  User: hasee
  Date: 2021/12/1
  Time: 14:23
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel = "stylesheet" href = "${pageContext.request.contextPath}/common/layui/css/layui.css">
    <script src = "${pageContext.request.contextPath}/common/jquery3.6.0.js"></script>
    <script src = "${pageContext.request.contextPath}/common/layui/layui.js"></script>
</head>
<body>
<div class="layui-form layuimini-form">


    <div class="layui-form-item">
        <label class="layui-form-label required">公告标题</label>
        <div class="layui-input-block">
            <input type="text" id = "caption" lay-reqtext="" value="" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">公告内容</label>
        <div class="layui-input-block">
            <textarea placeholder="请输入内容" id = "context" class="layui-textarea"></textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="demo1" id = "submit">提交</button>
        </div>
    </div>
</div>
<script type = "text/javascript">

    layui.use(['form', 'layedit', 'laydate'], function() {
        var form = layui.form,
            layer = layui.layer,
            layedit = layui.layedit,
            laydate = layui.laydate;

        document.querySelector("#submit").onclick = function(){
            var caption = $("#caption").val();
            var context = $("#context").val();

            $.ajax({
                url:"${pageContext.request.contextPath}/back/putNotice",
                type:"POST",
                data:{caption:caption,context:context},
                dataType:"json",
                success:function(req) {
                    if (req.flag == 1)
                    {
                        alert("加入新公告成功");
                    }
                }
            });

            //alert("caption:" + caption + "context:" + context);

        }




    });
</script>
</body>
</html>
